﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using fsw.Common;

namespace fsw.Web.Project
{
    public partial class Add : Web.UI.ManagePage
    {
        protected Model.Admin model_admin;
        protected void Page_Load(object sender, EventArgs e)
        {
            model_admin = GetAdminInfo();
            if (model_admin.TypeId > 1) Response.End(); 
            if (DTRequest.IsPost())
            {
                Response.Write(DoAdd());
                Response.End();
            }
        }
        protected string DoAdd()
        {
            string HosName = DTRequest.GetFormString("HosName");//项目名称
            int Pid = DTRequest.GetFormInt("Pid");//项目id
            string Remarks = DTRequest.GetFormString("Remarks");//弹窗路径                
            int OrderNo = DTRequest.GetFormInt("OrderNo");//排序    
            Model.Project model = new Model.Project();            
            model.HosName = HosName;
            model.Pid = Pid;
            model.Remarks = Remarks;
            model.CreateId = model_admin.Id;
            model.CreateDate = Utils.ConvertDateTimeInt(DateTime.Now);
            model.OrderNo = OrderNo;
            BLL.Project bll = new BLL.Project();
            if (bll.Add(model) > 0)
            {
                AdminAddLog(model_admin.Id,model_admin.UserName, "添加" + HosName + "项目成功!");
                DirFileHelper.CreateDirectory(Server.MapPath(DTKeys.Path_File + "/" + Pid.ToString() + "_" + HosName + "/"));
                return JsonErr("success", "添加项目成功!");
            }
            return JsonErr("error", "参数错误 ");
        }
    }
}